import { createApp } from "vue";
import App from "./App.vue";

import jmash, {
  store,
  routerRef,
  directive,
  useUserStore,
  getQueryParams,
  i18n,
  updateViteMetaEnv,
  axiosConfig
} from "./index";

//环境变量
const viteMetaEnv: ImportMetaEnv = import.meta.env;
const metaEnv = updateViteMetaEnv(viteMetaEnv);
axiosConfig(metaEnv);

import "@/permission";

const app = createApp(App);

//Query参数
const queryParams = getQueryParams();
if (queryParams.tenant) {
  useUserStore().user.tenant = queryParams.tenant;
} else {
  useUserStore().user.tenant = metaEnv.APP_TENANT;
}

app.use(jmash).use(store).use(directive).use(routerRef.value).use(i18n).mount("#app");
